﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="lp_Nissin_Bi.aspx.cs" Inherits="ZLDC.Estate.Quantify.lp_Nissin_Bi" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>日清日毕</title>
    <link href="../css/main.css" rel="stylesheet" type="text/css" />
 <script src="../js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>

    <script type="text/javascript">
        function Gen(t) {
            var tr = t.parentNode;
            while (tr.tagName != "TR") {
                tr = tr.parentNode;
            }
            if (!tr) {
                return;
            }
            if (tr.tagName != "TR") {
                return;
            }
            var gvView = document.getElementById("grView2");

            var rowIndex = gvView.rows.length - 1; //GridView 列表的最后一行


            if (t.value != "" && !isNaN(parseInt(t.value, 10))) {
                var scores = tr.cells[1].innerText; //分数
                var count = tr.cells[2].innerText; //数量
                var hscores = tr.cells[3].innerText; //最高分
                var sum = parseInt(t.value, 10) * (scores / count); //单项总分
                if (sum >= hscores) {
                    sum = hscores;
                }

                tr.cells[7].getElementsByTagName("input")[0].innerText = parseInt(sum, 10);





                var total = 0;
                for (var i = 1; i < rowIndex; i++) {

                    if (!isNaN(parseInt(gvView.rows[i].cells[7].childNodes[0].value, 10))) {
                        total = parseInt(total, 10) + parseInt(gvView.rows[i].cells[7].childNodes[0].value, 10);
                    } else {
                        total = total;
                    }
                }

                gvView.rows(rowIndex).cells(7).innerText = "总分：" + total;

            } else {

                tr.cells[7].getElementsByTagName("input")[0].innerText = "";


                var total = 0;
                for (var i = 1; i < rowIndex; i++) {

                    if (!isNaN(parseInt(gvView.rows[i].cells[7].childNodes[0].value, 10))) {
                        total = parseInt(total, 10) + parseInt(gvView.rows[i].cells[7].childNodes[0].value, 10);
                    } else {
                        total = total;
                    }
                }

                gvView.rows(rowIndex).cells(7).innerText = "总分：" + total;

            }
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <table width="100%" border="0" cellpadding="0" bgcolor="#CCCCCC">
       <%-- <tr>
            <td bgcolor="#F7F7F7">
                日期:<asp:TextBox ID="txtTime" runat="server" onfocus="WdatePicker({minDate:'%y-%M-{%d+1}'})"></asp:TextBox>
            </td>
        </tr>--%>
        <tr>
            <td bgcolor="#F7F7F7">
              <div style="height: 320px;overflow-x: auto; overflow-y: auto;Width:100%;" runat="server" id="div3">
                <asp:GridView ID="grView2" Style="text-align: center" runat="server" AutoGenerateColumns="False"
                    Width="100%" ShowFooter="True">
                    <Columns>
                        <asp:TemplateField HeaderText="序号">
                            <ItemTemplate>
                                <asp:Label ID="lblId" runat="server" Text='<%# Bind("id") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="BasisName" HeaderText="量化工作" />
                        <asp:TemplateField HeaderText="分值">
                            <ItemTemplate>
                                <asp:Label ID="lblpoint" runat="server" Text='<%# Bind("point") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="数量">
                            <ItemTemplate>
                                <asp:Label ID="lblquantity" runat="server" Text='<%# Bind("quantity") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                       <asp:BoundField DataField="unit" HeaderText="单位" />
                        
                        <asp:TemplateField HeaderText="最高分">
                            <ItemTemplate>
                                <asp:Label ID="lblHighest" runat="server" Text='<%# Bind("Highest") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="要求分数">
                            <ItemTemplate>
                                <asp:Label ID="lblSystemSouc" runat="server" Text='<%# Bind("SystemSouce") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="实际完成数量">
                            <ItemTemplate>
                                <asp:TextBox ID="txtCount" Width="40px" onblur="Gen(this)" runat="server"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="实际分数">
                            <ItemTemplate>
                                <asp:TextBox ID="txtSumScors" Width="40px" ReadOnly="true" runat="server"></asp:TextBox>
                            </ItemTemplate>
                            <FooterTemplate>
                                <asp:Label ID="lblTotal" align="left" runat="server" Text="总分：0"></asp:Label>
                            </FooterTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <HeaderStyle BackColor="#F1FADE" CssClass="fixHeaderStyle" />
                </asp:GridView>
                </div>
            </td>
        </tr>
        <tr>
            <td bgcolor="#F7F7F7" align="center">
                <asp:Button ID="btnSave" runat="server" Text=" 提 交 " CssClass="button_bak2" 
                    onclick="btnSave_Click" />
            </td>
        </tr>
    </form>
</body>
</html>
